/*
 * 创建日期 2005-10-8
 *
 * 更改所生成文件模板为
 * 窗口 > 首选项 > Java > 代码生成 > 代码和注释
 */
package com.vanda.report.element;

import com.vanda.report.ReportException;
import com.vanda.report.ReportInnerData;
import com.vanda.report.ReportOuterInterface;
import com.vanda.report.Validation;

/**
 * @author wkf5985
 *
 * 更改所生成类型注释的模板为
 * 窗口 > 首选项 > Java > 代码生成 > 代码和注释
 */
public class OutInterfaceElement extends Element {
	private String class_name;

	
	public void validator() throws ReportException{
		Validation.checkRequired("OutInterfaceElement","class_name",class_name);
	}
	
	/**
	 * 标签执行方法，递归执行
	 * @param obj
	 */
	public void execute(Object obj) throws ReportException{
		ReportInnerData reportData = (ReportInnerData)obj;
		
		try{
			//外部类实例
			ReportOuterInterface outObj = null;

			try{
				Class cls = Class.forName(class_name);

				//取得外部类实例
				outObj = (ReportOuterInterface)cls.newInstance();
			}catch(Exception e){
				throw new ReportException("Class["+class_name+"] is not exist!",e);
			}
			
			//执行外部类方法
			outObj.execute((ReportInnerData)obj);
			
		}catch(ReportException e){
			throw e;
		}catch(Exception e){
			throw new ReportException(e);
		}

	}
	
	/**
	 * @return
	 */
	public String getClass_name() {
		return class_name;
	}

	/**
	 * @param string
	 */
	public void setClass_name(String string) {
		class_name = string;
	}

}
